/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package battle.ship.model;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 *
 * @author Carlos
 */
public class Player implements  Serializable{
    protected String name;
    protected UUID id;
    protected List<Move> moves;
    protected Board board;
    

    public Player(String name) {
        this.name = name;
        this.id = UUID.randomUUID();
        this.moves = new ArrayList<>();
        this.board = new Board();
        
    }
    
    public Player() {
        this.name = " ";
        this.id = UUID.randomUUID();
        this.moves = new ArrayList<>();
        this.board = new Board();
        
    }
    
    
    public Board getBoard() {
        return this.board;
    }
    
    public List<Move> getMoves() {
        return this.moves;   
    }
    
    public UUID getID() {
        return this.id;
    }

    public String getName() {
        return this.name;
    }

    public void setNamePlayer(String name) {
        this.name = name;
    }
    
    public SquareType ProcessMove(Move move) {
        if (move == null){
            return SquareType.OUT;
        }
        for (Ship ship : this.board.getShips()) {
            for (Point point : ship.getPoints()) {
                if (point.equals(move.getPoint())){
                    return SquareType.BOAT;
                }
            }
        }
        return SquareType.WATTER;
    } 
}
